The operation of copying image pixels from a source address to a destination address can be used during image processing, wherein the operation includes image copying, image splicing, image splitting and the like; if specific algorithms, such as rotating the image, scaling the image, greying the image, making the image transparent and the like, are added in implementation steps, the implementation steps can be applied to most image processing operations after being modified and optimized slightly.
FIG. 1 shows a typical image copying application scene, fox example, a user accesses the Internet by using a mobile terminal to enter into an application of searching weather conditions in case that the user desires to acquire the weather conditions, a cache of the application (which can be abstracted as a source image data storage part) can save image data (namely, the source image) which illustrate the weather conditions; and a source image can be stored into a Liquid Crystal Display (LCD) to refresh a data cache (in a destination image data storage part) starting from a first pixel datum on the top left corner of the source image; meanwhile, some necessary indicating bars and icons, namely, the image (in an image copying data storage part) which is to be copied needs to be saved in a proper position of the destination image data storage part; as shown in FIG. 1, an image a starts its storage from the position shown by “initial line 1”; the initial line of an image b is the position shown by “initial line 2”, and the initial line of the source image is marked with “source image initial line”, as shown in the figure. The image to be copied and the source image (in an image display part) is the recombined and re-spliced (in an image processing part) into a destination image which is displayed on a mobile terminal screen and finally seen by a customer.
In the above-mentioned application scene, the source image and the image to be copied is combined into a destination image, namely, the image to be copied is overlapped (copied) to the source image to obtain the destination image. However, the destination image needs to be changed (for example stretching or widening and the like) by a certain ratio. In this application scene, the process of image copying is shown in FIG. 2, which includes the steps of:
step 201, the image copying starts;
step 202, judging whether the widths of the source image, the destination image and the image to be copied are all integer multiples of 4 bytes, and judging whether the image to be copied has the same width with a source image and with a destination image, if not, executing step 203, if so, executing step 206;
step 203, calling C library function memcpy( ) to copy a line of pixel data of the image to be copied to the destination address, and executing step 204 after completely copying the line of the pixel data;
step 204, starting to copy the next line of the pixel data (namely, moving the source address downward to a line relative to that in the step 203) of the image to be copied to a corresponding destination address (moving the destination address downward to a line relative to that in the step 203);
step 205, judging whether all the lines of the pixel data of the image to be copied are completely copied, if not, returning to the Step 203, if so, completing the image copying;
step 206, judging whether the width of the image to be copied is 32 bytes in the case of the source address, destination address and width of the image to be copied all being integer multiples of 4 bytes; if so, executing step 209, and then judging whether the height of the image to be copied is 16 lines, if so, executing step 210 to call the C library function memcpy( ) for 16 times, in which one line of the pixel data (namely, 32 bytes) is copied each time, until the copying process is completed; if the height is not 16 lines, returning to the step 203;
wherein if the width of the image to be copied is not 32 bytes, executing step 207, judging whether the source image has the same width with the destination image, if so, taking multiple lines of the image to be copied as one line and executing the step 203, if not, directly returning to the step 203.
The above-mentioned image copying method calls the C library function memcpy( ) to copy the images to be copied line by line, but such image processing process is time-consuming, and seriously occupies resources in a Central Processing Unit (CPU).